package registration.webapi;

import registration.Customer;
import registration.SalesManager;

import java.time.LocalDate;

public class CustomerDTO {
    private CustomerDTO() {
    }

    /**
     * 拼装 CustomerDto 类型的 DTO 对象
     *
     * @param customer 客户
     * @return DTO对象
     */
    public static CustomerDTO of(Customer customer) {
        CustomerDTO dto = new CustomerDTO();
        dto.id = customer.getCustomerId();
        dto.name = customer.getName().getText();
        dto.telephone = customer.getTelephone().getNumber();
        dto.address = customer.getAddress().getText();
        dto.areaSalesManager = null;
        return dto;
    }
    public CustomerDTO with(SalesManager areaSalesManager) {
        this.areaSalesManager = SalesManagerDTO.of(areaSalesManager);
        return this;
    }

    // 客户ID
    private Long id;

    // 客户姓名或公司名
    private String name;

    // 客户座机号码(必填项)
    private String telephone;

    // 客户联系地址(可选)
    private String address;

    // 注册成功起始日期YYYY-MM-DD
    private LocalDate memberSince;

    // 专属销售经理
    private SalesManagerDTO areaSalesManager;

    public SalesManagerDTO getAreaSalesManager() {
        return areaSalesManager;
    }

    public void setAreaSalesManager(SalesManagerDTO areaSalesManager) {
        this.areaSalesManager = areaSalesManager;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public LocalDate getMemberSince() {
        return memberSince;
    }

    public void setMemberSince(LocalDate memberSince) {
        this.memberSince = memberSince;
    }
}
